import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';
//createRouter方法:用来创建路由器对象 createRouter至少要传递一个配置对象
//createWebHashHistory hash模式  
////createWebHistory  history模式  
const router = createRouter({
    //路由模式 mode 
    history: createWebHashHistory(),
    //路由配置
    routes: [
        {
            path: '/home',
            component: () => import('../pages/home/index.vue'),
            meta: {
                title: '首页'
            },
            name: 'home',
            redirect: '/home/news',
            children: [
                {
                    path: 'news',
                    component: () => import('../pages/home/news/index.vue'),
                    meta: {
                        title: '新闻'
                    }
                },
                {
                    path: 'message',
                    component: () => import('../pages/home/message/index.vue'),
                    meta: {
                        title: '消息'
                    },
                    children:[
                        {
                            path:'detail',
                            component:()=>import('../pages/home/message/detail/index.vue'),
                            meta:{
                                title:'详情'
                            }
                        }
                    ]
                }
            ]
        },
        {
            path: '/about',
            component: () => import('../pages/about/index.vue'),
            meta: {
                title: '关于'
            },
            name: 'about',
        },
        {
            path: '/',
            redirect: '/home'
        },
        //任意路由:任意不包含home|about
        {
            path: '/:pathMatch(.*)*',
            component: () => import('../pages/404/index.vue'),
            meta: {
                title: '404'
            }
        }
    ]
});
export default router;







